package com.dk.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.dk.mapper.CarMapper;
import com.dk.pojo.Car;
import com.dk.pojo.CarExample;
import com.dk.service.CarService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
@org.springframework.stereotype.Service
public class CarServiceImpl implements CarService {

    @Autowired
    private CarMapper carMapper;
    @Override
    public List<Car> getInfo(Car car) {
        CarExample ce = new CarExample();
        CarExample.Criteria criteria = ce.createCriteria();
        criteria.andCnameLike(car.getCname());
        return  carMapper.selectByExample(ce);

    }

    @Override
    public int insert(Car car) {
        return carMapper.insert(car);
    }

    @Override
    public Car selectByCid(Integer cid) {
        return carMapper.selectByPrimaryKey(cid);
    }

    @Override
    public int updaateInfo(Car car) {
        return carMapper.updateByPrimaryKey(car);
    }

    @Override
    public int deleteById(Integer cid) {
        return carMapper.deleteByPrimaryKey(cid);
    }
}
